package biz.ezcom.design.pattern.memento;

/**
 * 游戏运行类 
 */
public class OriginatorGame {
	private State state;//游戏状态

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}
	
	/**
	 * 保存进度 
	 */
	public Memento saveMemento(){
		State save = (State) state.clone();
		return new Memento(save);
	}
	
	/**
	 * 加载进度
	 */
	public void loadMemento(Memento memento){
		setState(memento.getState());
	}
	/**
	 * 显示状态
	 */
	public void show(){
		System.out.println(getState());
	}
	/**
	 * 玩游戏
	 */
	public void play(){
		System.out.println("正在完游戏");
		state.setAttack(state.getAttack() - 10);
		state.setDefense(state.getDefense() - 10);
		state.setVitality(state.getVitality() - 10);
		System.out.println("攻击力，防御力，生命值都下降了10");
	}
}
